<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/plugin/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
</head>
<body>
	<div class="ibox-content">
		<form class="form-horizontal" id="dataform"
			onsubmit="javascripr:return false;">
			<input type="hidden" name="tokenUrl" value="${tokenUrl}"> <input
				type="hidden" name="token" value="${token}">
			<c:if test="${obj ne null }">
				<input type="hidden" name="proId" value="${obj.proId }">
				<input type="hidden" id="proTypeId" value="${obj.proType}">
			</c:if>
			<div class="form-group">
				<label class="col-sm-2 control-label">产品分类 <span
					class="text-danger">*</span>
				</label>
				<div class="col-sm-4">
					<select class="select2 form-control " size="1" name="proType" dataType="*1-20" id="proType">
						<!-- <option value="0" selected="selected">--请选择产品类别--</option> -->
					</select>
				</div>
				<label class="col-sm-2 control-label">产品名称 <span
					class="text-danger">*</span>
				</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" name="proName" maxlength="20"
						dataType="s1-20" id="proName"
						value="<c:out value="${obj.proName }"></c:out>" nullmsg="产品名称不能为空">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">价格 <span
					class="text-danger">*</span>
				</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" name="proPrice" maxlength="10"
						dataType="n1-10" id="proPrice"
						value="<c:out value="${obj.proPrice }"></c:out>" nullmsg="价格不能为空">
				</div>
				<label class="col-sm-2 control-label">状态</label>
				<div class="col-sm-4">
					<select class="form-control  select2" name="proState">
						<option <c:if test="${obj.proState eq '1'}">selected="selected"</c:if> value="1">上架</option>
						<option <c:if test="${obj.proState eq '2'}">selected="selected"</c:if> value="2">未上架</option>
					</select>
				</div>
			</div>
			<div class="form-group ">
				<label class="col-sm-2 control-label">产地 </label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="proProvince" maxlength="100" dataType="*" name="proProvince"
						value="<c:out value="${obj.proProvince }"></c:out>" nullmsg="规格说明不能为空" ignore="ignore">
				</div>
				<label class="col-sm-2 control-label">规格说明 <span class="text-danger"></span></label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="proSize" maxlength="150" dataType="*" name="proSize"
						value="<c:out value="${obj.proSize }"></c:out>" nullmsg="规格说明不能为空">
				</div>
			</div>
			<div class="form-group ">
				<label class="col-sm-2 control-label">简要描述 <span class="text-danger">*</span></label>
				<div class="col-sm-10">
					<textarea type="text" class="form-control" name="proDescription"
						maxLength="1500" dataType="*1-1500" style="height:200px;resize:none;"
						nullmsg="简要描述不能为空"><c:out value="${obj.proDescription }"></c:out></textarea>
				</div>
			</div>
<!-- 			<div class="form-group "> -->
<!-- 				<label class="col-sm-2 control-label">型号 <span -->
<!-- 					class="text-danger"></span> -->
<!-- 				</label> -->
<!-- 				<div class="col-sm-4"> -->
<!-- 					<input type="text" class="form-control" name="proModel" -->
<!-- 						ignore="ignore" maxi="20" dataType="*1-10" id="proModel" -->
<%-- 						value="<c:out value="${obj.proModel }"></c:out>" nullmsg="型号不能为空"> --%>
<!-- 				</div> -->
<!-- 				<label class="col-sm-2 control-label">材质 <span -->
<!-- 					class="text-danger"></span> -->
<!-- 				</label> -->
<!-- 				<div class="col-sm-4"> -->
<!-- 					<input type="text" class="form-control" name="proMaterial" -->
<!-- 						ignore="ignore" maxi="20" dataType="*1-10" id="proMaterial" -->
<%-- 						value="<c:out value="${obj.proMaterial }"></c:out>" --%>
<!-- 						nullmsg="材质不能为空"> -->
<!-- 				</div> -->
<!-- 			</div> -->
<!-- 			<div class="form-group"> -->
<!-- 				<label class="col-sm-2 control-label">产地 </label> -->
<!-- 				<div class="col-sm-4"> -->
<!-- 					<select class="form-control autoFull select2 proProvince" -->
<!-- 						id="proProvince" -->
<%-- 						data-url="${path}/admin/busArea/showList?parentId=0" --%>
<!-- 						data-value="areaName" data-filed="areaName" -->
<%-- 						data-def="${obj.proProvince}" name="proProvince"> --%>
<!-- 						<option value="">--无--</option> -->
<!-- 					</select> <select class="form-control autoFull select2 proCity" id="proCity" -->
<%-- 						data-url="${path}/admin/busArea/findArea" --%>
<%-- 						data-param="{areaName:'${obj.proProvince}'}" data-value="areaName" --%>
<%-- 						data-filed="areaName" data-def="${obj.proCity}" name="proCity"> --%>
<!-- 						<option value="">--无--</option> -->
<!-- 					</select> <select class="form-control autoFull select2 proZone" id="proZone" -->
<%-- 						data-url="${path}/admin/busArea/findArea" --%>
<%-- 						data-param="{areaName:'${obj.proCity}'}" data-value="areaName" --%>
<%-- 						data-filed="areaName" data-def="${obj.proZone}" name="proZone"> --%>
<!-- 						<option value="">--无--</option> -->
<!-- 					</select> -->
<!-- 				</div> -->
<!-- 			</div> -->
			
			<!-- 			<div class="form-group "> -->
			<!-- 				<label class="col-sm-2 control-label">设计元素 <span -->
			<!-- 					class="text-danger"></span> -->
			<!-- 				</label> -->
			<!-- 				<div class="col-sm-4"> -->
			<!-- 					<input type="text" class="form-control" name="proDesignElement" -->
			<!-- 						ignore="ignore" maxi="20" dataType="*1-10" id="proDesignElement" -->
			<%-- 						value="<c:out value="${obj.proDesignElement }"></c:out>" --%>
			<!-- 						nullmsg="设计元素不能为空"> -->
			<!-- 				</div> -->
			<!-- 				<label class="col-sm-2 control-label">颜色分类 <span -->
			<!-- 					class="text-danger"></span> -->
			<!-- 				</label> -->
			<!-- 				<div class="col-sm-4"> -->
			<!-- 					<input type="text" class="form-control" name="proColor" -->
			<!-- 						ignore="ignore" maxi="20" dataType="*1-10" id="proColor" -->
			<%-- 						value="<c:out value="${obj.proColor }"></c:out>" --%>
			<!-- 						nullmsg=" 颜色分类不能为空"> -->
			<!-- 				</div> -->
			<!-- 			</div> -->
<!-- 			<div class="form-group "> -->
<!-- 				<label class="col-sm-2 control-label">适用对象 <span -->
<!-- 					class="text-danger"></span> -->
<!-- 				</label> -->
<!-- 				<div class="col-sm-4"> -->
<!-- 					<input type="text" class="form-control" name="proUser" -->
<!-- 						ignore="ignore" maxi="20" dataType="*1-10" id="proUser" -->
<%-- 						value="<c:out value="${obj.proUser }"></c:out>"> --%>
<!-- 				</div> -->
<!-- 				<label class="col-sm-2 control-label">可送货安装地区<span -->
<!-- 					class="text-danger">*</span></label> -->
<!-- 				<div class="col-sm-4"> -->
<!-- 					<select class="form-control autoFull select2 proInstallArea" -->
<!-- 						dataType="*" nullmsg="不能为空" multiple="multiple" ignore="ignore" -->
<%-- 						data-url="${path}/admin/busArea/showList?parentId=0" --%>
<!-- 						data-value="areaName" data-filed="areaName" -->
<%-- 						data-def="${obj.proInstallArea}" name="proInstallArea"> --%>
<!-- 					</select> -->
<!-- 				</div> -->
<!-- 			</div> -->
<!-- 			<div class="form-group "> -->
<!-- 				<label class="col-sm-2 control-label">品牌 <span -->
<!-- 					class="text-danger"></span> -->
<!-- 				</label> -->
<!-- 				<div class="col-sm-4"> -->
<!-- 					<input type="text" class="form-control" name="proBrand" nullmsg="品牌不能为空" -->
<!-- 					 maxlength="30" dataType="*1-30" id="proBrand" ignore="ignore" -->
<%-- 						<c:if test="${obj.proBrand eq null}">value="Ashley爱室丽家居"</c:if> --%>
<%-- 						<c:if test="${obj.proBrand ne null}">value="<c:out value="${obj.proBrand }"></c:out>"</c:if> > --%>
<!-- 				</div> -->
<!-- 				<label class="col-sm-2 control-label">销量 <span -->
<!-- 					class="text-danger"></span> -->
<!-- 				</label> -->
<!-- 				<div class="col-sm-4"> -->
<!-- 					<input type="text" class="form-control" name="proSalesTotal" nullmsg="销量不能为空" -->
<!-- 						ignore="ignore" maxlength="10" dataType="n1-10" id="proSalesTotal" -->
<%-- 						<c:if test="${obj.proSalesTotal eq null}">value="0"</c:if> --%>
<%-- 						<c:if test="${obj.proSalesTotal ne null}">value="<c:out value="${obj.proSalesTotal }"></c:out>"</c:if> > --%>
<!-- 				</div> -->
<!-- 			</div> -->
			<div class="form-group ">
				<div class="col-sm-12 text-center">
					<a href="javascript:;" onclick="myForm.submit()"
						class="btn btn-success radius"><i class="fa fa-check"></i> 保存</a>&nbsp;&nbsp;&nbsp;&nbsp;
					<a class="btn btn-danger radius" href="javascript:;"
						onclick="MTools.closeForm()"><i class="fa fa-close"></i> 关闭</a>
				</div>
			</div>
		</form>
	</div>
</body>
<script type="text/javascript"
	src="${path }/resource/js/systools/MJsBase.js"></script>
<script type="text/javascript">
	$(function() {
		MTools.autoFullSelect();
		$(".select2").select2();
		initFunctionList();
	});

	var myForm = MForm.initForm({
		invokeUrl : "${path}/admin/distributionProduct/addOrModify",
		afterSubmit : function() {
			parent.myGrid.serchData();
		},
	});

	$(".proProvince")
			.change(
					function() {
						$('.proCity').html('<option value="">--无--</option>');
						$('.proZone').html('<option value="">--无--</option>');
						var id = $(this).attr("id");
						if (id == "proProvince") {
							if ($("#" + id).val() != ""
									&& $("#proProvince option:selected").text() != "--无--") {
								$("#proCity").html("");
								$("#proCity").data(
										"param",
										"{areaName:'" + $("#proProvince").val()
												+ "'}");
								$("#proCity").data("url",
										"${path}/admin/busArea/findArea");
								MTools.autoFullSelect("#proCity");
							}
						}
					});
	$(".proCity")
			.change(
					function() {
						$('.proZone').html('<option value="">--无--</option>');
						var id = $(this).attr("id");
						console.log(id);
						if (id == "proCity") {
							if ($("#" + id).val() != ""
									&& $("#proCity option:selected").text() != "--无--") {
								$("#proZone").html("");
								$("#proZone").data(
										"param",
										"{areaName:'" + $("#proCity").val()
												+ "'}");
								$("#proZone").data("url",
										"${path}/admin/busArea/findArea");
								MTools.autoFullSelect("#proZone");
							}
						}
					});
	/**
	 * 初始产品分类列表
	 */
	function initFunctionList() {
		$.AjaxProxy()
				.invoke(
						"${path}/admin/distributionCategory/all",
						function(loj) {
							$("#proType").createSelectTree(
											loj.attr("result").rows,
											{
												id : "catId", // 选项的值
												parent : "catParentId", // 父节点值
												value : "catName", // 要显示的名称
												append : false,
												disabledParent : true, // 父节点是否禁止可选
												defaultValue : $("#proTypeId")
														.val(),
												defaultHtml : '<option value="" selected="selected">请选择产品类别</option>'
											});
						});
	}
</script>
</body>
</html>